﻿using IdentityServer3.Core.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EmbeddedMVC
{
    public static class Clients
    {
        private static string redirecturl = System.Configuration.ConfigurationManager.AppSettings["RedirectUri"].ToString();
        public static IEnumerable<Client> Get()
        {
            return new[]
            {

            //本地客户端
            new Client
            {
                Enabled = true,
                ClientName = "MVC Client",
                ClientId = "mvc",
                Flow = Flows.Implicit,

                RedirectUris = new List<string>
                {
                    redirecturl
                },

                PostLogoutRedirectUris = new List<string>
               {
                  redirecturl
                },

               AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "sampleApi"
               }
            },

            //api 客户端
            new Client
            {
                ClientName = "MVC Client (service communication)",
                ClientId = "mvc_service",
                Flow = Flows.ClientCredentials,

                ClientSecrets = new List<Secret>
                {
                    new Secret("secret".Sha256())
                },
                AllowedScopes = new List<string>
                {
                    "sampleApi"
                }
            },

            //client1
             new Client
            {
                Enabled = true,
                ClientName = "client1",
                ClientId = "client1",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                LogoutUri = "http://localhost:24667/Account/SignoutCleanup",
                 RedirectUris = new List<string>
                    {
                        "http://localhost:24667/"
                    },
                 PostLogoutRedirectUris = new List<string>
                    {
                        "http://localhost:24667/"
                    }
            },

              new Client
            {
                Enabled = true,
                ClientName = "client2",
                ClientId = "client2",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                 RedirectUris = new List<string>
                    {
                        "http://www.client2.com/"
                    },
                   PostLogoutRedirectUris = new List<string>
                    {
                        "http://www.client2.com/"
                    }
            },
               new Client
            {
                Enabled = true,
                ClientName = "webformclient",
                ClientId = "webformclient",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                 RedirectUris = new List<string>
                    {
                        "http://localhost:10752/"
                    },
                   PostLogoutRedirectUris = new List<string>
                    {
                        "http://localhost:10752/"
                    }
            },
                new Client
            {
                Enabled = true,
                ClientName = "webformclient40",
                ClientId = "webformclient40",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                 RedirectUris = new List<string>
                    {
                        "http://localhost:10731/"
                    },
                   PostLogoutRedirectUris = new List<string>
                    {
                        "http://localhost:10731/"
                    }
            },
                 new Client
            {
                Enabled = true,
                ClientName = "Acadsoc",
                ClientId = "Acadsoc",
                Flow = Flows.Implicit,
                AllowAccessTokensViaBrowser=false,
                RequireConsent = false,
                AllowRememberConsent = true,
                AllowedScopes = new List<string>
               {
                    "openid",
                    "profile",
                    "roles",
                    "email"
               },
                 RedirectUris = new List<string>
                    {
                        "http://localhost:60631/"
                    },
                   PostLogoutRedirectUris = new List<string>
                    {
                        "http://localhost:60631/"
                    }
            }
        };
        }
    }
}